package Controller.reply;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

import Bean.ReplyBean;
import Dao.ReplyDao;

public class ReplyListController implements Controller{
	private ReplyDao dao;
	
	public void setDao(ReplyDao dao) {
		this.dao = dao;
	}

	@Override
	public ModelAndView handleRequest(HttpServletRequest req,
			HttpServletResponse arg1) throws Exception {
		System.out.println("Reply 리스트 컨트롤러");
		Integer sr_sb_no = Integer.parseInt(req.getParameter("sb_no"));
		/*Integer sr_myno = Integer.parseInt(req.getParameter("sr_myno"));*/
		ModelAndView mav = new ModelAndView();
		List<ReplyBean> reply = dao.replySelect(sr_sb_no);

		if(reply == null){
			mav.setViewName("InsertreplyError");
			mav.addObject("sb_no", sr_sb_no);
			return mav;
		}else{
		mav.setViewName("reply");
		mav.addObject("reply", reply);
		mav.addObject("sb_no", sr_sb_no);
		return mav;
		}
	}

}
